package com.itzh.nio;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;

public class NIOFileChannel04 {
    public static void main(String[] args) throws IOException {
        FileInputStream fileInputStream = new FileInputStream("C:\\Users\\周志军\\Desktop\\壁纸\\1.jpg");
        FileOutputStream fileOutputStream = new FileOutputStream("C:\\Users\\周志军\\Desktop\\壁纸\\2.jpg");

        FileChannel sourceChannel = fileInputStream.getChannel();
        FileChannel destch = fileOutputStream.getChannel();

        //transferForm完成拷贝
        destch.transferFrom(sourceChannel,0,sourceChannel.size());
        fileInputStream.close();
        fileOutputStream.close();
    }
}
